<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ywc="http://www.iter.org/ywc" exclude-result-prefixes="xs xsl ywc">
<xsl:param name="uri" as="xs:string" select="'/'" />
<xsl:param name="params" as="xs:string" select="''" />
<xsl:param name="lang" as="xs:string" select="'en'" />
<xsl:param name="cache_path" as="xs:string" select="'-'" />
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" />

<xsl:include href="../../../ywc/1.0/inc/ywc-core.xsl" />
<xsl:include href="../../../ywc/1.0/inc/ywc-convert.xsl" />
<xsl:include href="../../../ywc/1.0/ui-elements/ywc-header.xsl" />

<xsl:variable name="linkTitle" select="ywc:getParam('linkTitle',$params)"/>

<xsl:template match="/">
	
	<xsl:variable name="menus-xml" select="ywc:returnYwcCache('links')/menus/menu/item" />
	
	<xsl:choose>
	<xsl:when test="string-length($linkTitle) = 0">
		
		<xsl:for-each select="$menus-xml[@depth = 1]">
		
			<xsl:call-template name="ywcHeader">
				<xsl:with-param name="text" select="@title"/>
				<xsl:with-param name="width" select="120"/>
				<xsl:with-param name="fontsize" select="if (position() = 1) then 20 else 14"/>
				<xsl:with-param name="color" select="'c70019'"/>
				<xsl:with-param name="bg-color" select="'c9c0bb'"/>
				<xsl:with-param name="use-stroke" select="1"/>
			</xsl:call-template>	
		
			<xsl:for-each select="item[@depth = 2]">
				<div class="quicklink" title="{lower-case(@title)}" onClick='{
					if (count(./*) = 0) then concat("window.open(&apos;",@url,"&apos;);")
					else "YWC.f.intranetPopupQuickLinks(this);"
				}'>
					<div class="quicklink_on">
						<xsl:value-of select="@title" /><xsl:if test="count(./*) &gt; 0"> &gt;&gt;</xsl:if>
					</div>
				</div>
			
				<br />
			
			</xsl:for-each>			

		</xsl:for-each>
	
	</xsl:when>
	<xsl:otherwise>
	
		<xsl:call-template name="ywcHeader">
			<xsl:with-param name="text" select="$linkTitle"/>
			<xsl:with-param name="width" select="120"/>
			<xsl:with-param name="fontsize" select="14"/>
			<xsl:with-param name="color" select="'c70019'"/>
			<xsl:with-param name="bg-color" select="'c9c0bb'"/>
			<xsl:with-param name="use-stroke" select="1"/>
		</xsl:call-template>
		
		<xsl:for-each select="$menus-xml/item[lower-case(@title) = lower-case($linkTitle)]/item">
			
			<div class="quicklink">
				<div class="quicklink_on" title="{lower-case(@title)}">
					<xsl:attribute name="onClick">
						<xsl:value-of select='concat("window.open(&apos;",@url,"&apos;);")' />
					</xsl:attribute>
					<xsl:value-of select="@title" />
				</div>
			</div>
		
			<br />
			
		</xsl:for-each>
		
	</xsl:otherwise>
	</xsl:choose>

</xsl:template>

</xsl:stylesheet>
